home *** CD-ROM | disk | FTP | other *** search
- Path: dd.chalmers.se!news.chalmers.se!sunic!ugle.unit.no!trane.uninett.no!eunet.no!EU.net!howland.reston.ans.net!europa.eng.gtefsd.com!darwin.sura.net!osceola.cs.ucf.edu!longwood.cs.ucf.edu!not-for-mail
- From: kruse@longwood.cs.ucf.edu (Holger Kruse)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Re: Removing Task started with CreateNewProc
- Date: 11 Apr 1994 17:45:44 -0400
- Organization: University of Central Florida
- Lines: 52
- Message-ID: <2ocge8$mpo@longwood.cs.ucf.edu>
- References: <rknopCo3z57.Azo@netcom.com>
- NNTP-Posting-Host: longwood.cs.ucf.edu
-
- rknop@netcom.com (Robert Knop) writes:
-
- >I have a parent process that creates a child process with the dos.library
- >CreateNewProc, using the NP_Entry tag (as opposed to the NP_SegList tag).
- >When I want to finish the task, the parent process sends a message to the
- >child process, telling it to clean up. The child process cleans up
- >_everything_ it has allocated, and then does:
-
- >ReplyMsg(msg);
- >Wait(0L);
-
- >When the parent process gets the reply to the "clean up" message, it takes
- >that to mean that the child process is cleaned up and ready to be killed, so
- >it calls RemTask(childprocess).
-
- I see two problems with your method:
- - Exec might preempt your child task during ReplyMsg(msg), so when
- you RemTask() it, it is still within the ReplyMsg(), and has not
- yet reached the Wait(). This might not be fatal though.
- - Here is the real problem: RemTask() should not be used for DOS
- processes, because DOS processes have a DOS environment, that
- needs cleanup, too. This is done automatically for you if you
- just "fall through", i.e. execute a RTS at the end of your
- subroutine. Then the program executes the necessary DOS-related
- cleanup and removes the task from exec's list.
-
- The code I use in one of my programs looks like this:
-
- main process:
-
- CreateNewProc(....)
- -- some synchronization for startup --
- [...task is running...]
- Wait(SIGBREAKF_CTRL_F); /* I guess you could use messages instead of
- signals here, too) */
- /* nothing else to do here. Child task has finished */
-
- child process:
-
- -- some synchronization for startup --
- [... task is running ...]
- Forbid(); /* necessary to make sure that the task is really removed
- before the main program _assumes_ that it is gone. */
- Signal(parent,SIGBREAKF_CTRL_F);
- /* fall through to the end of the C function */
-
- If you use messages instead of signals the synchronization gets quite
- similar to the one used by Workbench.
-
- Holger Kruse
- kruse@cs.ucf.edu
-